// 获得护驾时解锁神魔录，辨识度100%。
let SWDA_Game_Party_gainItem = Game_Party.prototype.gainItem;
Game_Party.prototype.gainItem = function(item, amount, includeEquip) {
    SWDA_Game_Party_gainItem.call(this, item, amount, includeEquip);
    let id = {};
    if (item && amount > 0) {
        if (DataManager.isArmor(item)) {
            if(item.itemCategory.contains('护驾')){
                if(!!item.enemyId){
                    id = item.enemyId;
                    $gameSystem.completeEnemyIdentify(id);
                    if(!$gameParty.inBattle())
                        DataManager.saveGlobalEnemyBook();  //存储神魔录
                }
            }
        }
    }
};

// 暴怒确定机关人目标
Game_Party.prototype.jgrTarget = function() {
    var target = null;
    this.aliveMembers().forEach(function(member) {
        if (member.actorId()==2) {
            target = member;
        }
    });
    return target;
};

// 记忆指令：区分战斗物品和菜单物品
let SWDA_Game_Party_initialize = Game_Party.prototype.initialize;
Game_Party.prototype.initialize = function() {
    SWDA_Game_Party_initialize.call(this);
    this._lastBattleItem = new Game_Item();
};

Game_Party.prototype.lastItem = function() {
    let item = new Game_Item();
    if(!this._lastBattleItem)
        this._lastBattleItem = new Game_Item();
    if(!this._lastItem)
        this._lastItem = new Game_Item();
    
    if (this.inBattle()) {
        item = this._lastBattleItem
    } else {
        item = this._lastItem
    }
    return item.object();
};

Game_Party.prototype.setLastItem = function(item) {
    if (this.inBattle()) {
        this._lastBattleItem.setObject(item);
    } else {
        this._lastItem.setObject(item);
    }
};

// 记忆指令：炼妖物品
Game_Party.prototype.lastSynthesisItem = function() {
    let item = new Game_Item();
    if(!this._lastSynthesisItem)
        this._lastSynthesisItem = new Game_SynthesisItem();
    item = this._lastSynthesisItem
    return item.object();
};

Game_Party.prototype.setLastSSynthesisItem = function(item) {
    if(!this._lastSynthesisItem)
        this._lastSynthesisItem = new Game_SynthesisItem();
    this._lastSynthesisItem.setObject(item);
};

// 记忆指令：神魔录
Game_Party.prototype.lastEnemyBookEnemy = function() {
    let lastSelectInfo = null;
    if(!this._lastEnemyBookEnemy)
        this._lastEnemyBookEnemy = null;
    lastSelectInfo = this._lastEnemyBookEnemy
    return lastSelectInfo;
};

Game_Party.prototype.setLastEnemyBookEnemy = function(lastSelectInfo) {
    if(!this._lastEnemyBookEnemy)
        this._lastEnemyBookEnemy = null;
    this._lastEnemyBookEnemy = lastSelectInfo;
};
